home *** CD-ROM | disk | FTP | other *** search
- Path: newsbf02.news.aol.com!not-for-mail
- From: roberino@aol.com (Roberino)
- Newsgroups: comp.lang.c
- Subject: HELP! File Pointers
- Date: 8 Jan 1996 23:32:12 -0500
- Organization: America Online, Inc. (1-800-827-6364)
- Sender: root@newsbf02.news.aol.com
- Message-ID: <4csr4c$fem@newsbf02.news.aol.com>
- Reply-To: roberino@aol.com (Roberino)
- NNTP-Posting-Host: newsbf02.mail.aol.com
-
- I am currently trying to keep one file open while opening other
- files one at a time using a separate file pointer. However, as
- soon as I read a line from the second file, the first file pointer
- somehow gets destroyed and set to some position in the newly
- opened file. Has anyone else encountered this? And if so,
- is there a solution? (i.e. A way to protect the first file pointer
- from being overwritten.)
-
- Here are the steps I am performing:
-
- void main()
- {
- FILE *File1;
- FILE *File2;
-
- File1 = fopen("FILENAME", "r+");
-
- /* loop through lines in File1 using fgets() */
-
- if (Condition) /* just indicating some condition was met */
- {
- File2 = fopen("FILENAME2", "r+");
-
- fgets(Line, File2); <----- As soon as this occurs, File1 gets
- wiped out. Why?
- }
- }
-
- Please send any and all replies through email to
- roberino@aol.com.
- I appreciate any and all help.
-
- Thank you,
- Rob
-